import type { FieldConfig } from '@/components/TableFilter.vue'
import { getFormFields } from '@/utils/formUtils'
import type { FormFieldConfig } from '@/types/form'

// 表格列配置
export const tableColumns = [
  {
    title: '來源ID',
    dataIndex: 'id',
  },
  {
    title: 'CODE',
    dataIndex: 'code',
  },
  {
    title: '名稱',
    dataIndex: 'name',
  },

  {
    title: '業務大類',
    dataIndex: 'category',
  },
  {
    title: '分類',
    dataIndex: 'catName',
  },
  {
    title: '子分類',
    dataIndex: 'subCatName',
  },
  {
    title: '類別',
    dataIndex: 'class',
  },
  {
    title: 'Team Code',
    dataIndex: 'teamCode',
  },
  {
    title: '最後修改時間',
    dataIndex: 'updatedAt',
  },
  {
    title: '操作',
    key: 'action',
    align: 'center',
  },
]
// 過濾項配置
export const filterFields: FieldConfig[] = [
  {
    name: 'code',
    label: '產品CODE',
    type: 'input',
    placeholder: '請輸入產品CODE',
  },
  {
    name: 'name',
    label: '產品名稱',
    type: 'input',
    placeholder: '請輸入產品名稱',
  },
  {
    name: 'category',
    label: '業務大類',
    type: 'select',
    options: [
      { value: '', label: '全部' },
      { value: 'prescription', label: '處方' },
      { value: 'cordyceps', label: '蟲草' },
      { value: 'nest', label: '燕窩' },
      { value: 'angong', label: '安宮系列' },
      { value: 'wyt', label: '本廠' },
      { value: 'oem', label: 'OEM' },
      { value: 'acupuncture', label: '針灸' },
      { value: 'tianjiu', label: '天灸' },
      { value: 'finished_goods', label: '成品' },
      { value: 'package', label: '套餐' },
      { value: 'unknown', label: 'unknown' },
    ],
    placeholder: '請輸入產品大類',
  },
  {
    name: 'catName',
    label: '分類',
    type: 'input',
    placeholder: '請輸入分類',
  },
  {
    name: 'class',
    label: '類別',
    type: 'input',
    placeholder: '請輸入類別',
  },
  {
    name: 'team_code',
    label: 'Team Code',
    type: 'input',
    placeholder: '請輸入Team Code',
  },
]

// 表單字段配置
// 諮詢費、中藥、蟲草、成品、天灸、針灸、燕窩、安宮、OEM、套餐
const FormField: Record<string, FormFieldConfig> = {
  category: {
    label: '業務大類',
    type: 'select',
    placeholder: '請輸入業務大類',
    options: [
      { key: 'prescription', label: '處方' },
      { key: 'cordyceps', label: '蟲草' },
      { key: 'nest', label: '燕窩' },
      { key: 'angong', label: '安宮系列' },
      { key: 'wyt', label: '本廠' },
      { key: 'oem', label: 'OEM' },
      { key: 'acupuncture', label: '針灸' },
      { key: 'tianjiu', label: '天灸' },
      { key: 'finished_goods', label: '成品' },
      { key: 'package', label: '套餐' },
    ],
    rules: [{ required: true, message: '請選擇業務大類' }],
  },
}

export const getEditFieldConfig = (fields?: string[]) => {
  return getFormFields(FormField, fields)
}
